<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Integer Real World Tests</title>
<link rel="stylesheet" href="../../multiprecision.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Multiprecision">
<link rel="up" href="../perf.html" title="Performance Comparison">
<link rel="prev" href="realworld.html" title="Floating-Point Real World Tests">
<link rel="next" href="rational_real_world.html" title="Rational Real World Tests">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="realworld.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rational_real_world.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_multiprecision.perf.int_real_world"></a><a class="link" href="int_real_world.html" title="Integer Real World Tests">Integer Real
      World Tests</a>
</h3></div></div></div>
<p>
        The first set of <a href="http://www.boost.org/doc/libs/release/libs/multiprecision/doc/html/../../performance/voronoi_performance.cpp" target="_top">tests</a>
        measure the times taken to execute the multiprecision part of the Voronoi-diagram
        builder from Boost.Polygon. The tests mainly create a large number of temporaries
        "just in case" multiprecision arithmetic is required, for comparison,
        also included in the tests is Boost.Polygon's own partial-multiprecision
        integer type which was custom written for this specific task:
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Integer Type
                </p>
              </th>
<th>
                <p>
                  Relative Performance (Actual time in parenthesis)
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  checked_int1024_t
                </p>
              </td>
<td>
                <p>
                  1.53714(0.0415328s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int256_t
                </p>
              </td>
<td>
                <p>
                  1.20715(0.0326167s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int512_t
                </p>
              </td>
<td>
                <p>
                  1.2587(0.0340095s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int
                </p>
              </td>
<td>
                <p>
                  1.80575(0.0487904s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  extended_int
                </p>
              </td>
<td>
                <p>
                  1.35652(0.0366527s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int1024_t
                </p>
              </td>
<td>
                <p>
                  1.36237(0.0368107s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int256_t
                </p>
              </td>
<td>
                <p>
                  1(0.0270196s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int512_t
                </p>
              </td>
<td>
                <p>
                  1.0779(0.0291243s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int
                </p>
              </td>
<td>
                <p>
                  3.83495(0.103619s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int
                </p>
              </td>
<td>
                <p>
                  41.6378(1.12504s)
                </p>
              </td>
</tr>
</tbody>
</table></div>
<p>
        Note how for this use case, any dynamic allocation is a performance killer.
      </p>
<p>
        The next <a href="http://www.boost.org/doc/libs/release/libs/multiprecision/doc/html/../../performance/miller_rabin_performance.cpp" target="_top">tests</a>
        measure the time taken to generate 1000 128-bit random numbers and test for
        primality using the Miller Rabin test. This is primarily a test of modular-exponentiation
        since that is the rate limiting step:
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Integer Type
                </p>
              </th>
<th>
                <p>
                  Relative Performance (Actual time in parenthesis)
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  checked_uint1024_t
                </p>
              </td>
<td>
                <p>
                  9.52301(0.0422246s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int
                </p>
              </td>
<td>
                <p>
                  11.2194(0.0497465s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (1024-bit cache)
                </p>
              </td>
<td>
                <p>
                  10.7941(0.0478607s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (128-bit cache)
                </p>
              </td>
<td>
                <p>
                  11.0637(0.0490558s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (256-bit cache)
                </p>
              </td>
<td>
                <p>
                  11.5069(0.0510209s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (512-bit cache)
                </p>
              </td>
<td>
                <p>
                  10.3303(0.0458041s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  16.1792(0.0717379s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int
                </p>
              </td>
<td>
                <p>
                  1.05106(0.00466034s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  1(0.00443395s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int
                </p>
              </td>
<td>
                <p>
                  5.10595(0.0226395s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  61.9684(0.274765s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  uint1024_t
                </p>
              </td>
<td>
                <p>
                  9.32113(0.0413295s)
                </p>
              </td>
</tr>
</tbody>
</table></div>
<p>
        It's interesting to note that expression templates have little effect here
        - perhaps because the actual expressions involved are relatively trivial
        in this case - so the time taken for multiplication and division tends to
        dominate. The much quicker times from GMP and tommath are down to their much
        better modular-exponentiation algorithms (GMP's is about 5x faster). That's
        an issue which needs to be addressed in a future release for <a class="link" href="../tut/ints/cpp_int.html" title="cpp_int">cpp_int</a>.
      </p>
<div class="table">
<a name="boost_multiprecision.perf.int_real_world.platform"></a><p class="title"><b>Table 1.17. Platform Details</b></p>
<div class="table-contents"><table class="table" summary="Platform Details">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              </th>
<th>
                <p>
                  Version
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  Compiler
                </p>
              </td>
<td>
                <p>
                  GNU C++ version 10.3.0
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  GMP
                </p>
              </td>
<td>
                <p>
                  6.2.0
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  MPFR
                </p>
              </td>
<td>
                <p>
                  262146
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  Boost
                </p>
              </td>
<td>
                <p>
                  107800
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  Run date
                </p>
              </td>
<td>
                <p>
                  Sep 30 2021
                </p>
              </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2002-2020 John
      Maddock and Christopher Kormanyos<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="realworld.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="rational_real_world.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
